/*
* This code controls a 6 element charlieplexed plane of LEDs without any switch to start the routine.
*/

int A = 3; 
int B = 2;
int C = 1;

// initialization
void setup()
{
    pinMode(A, INPUT);
    pinMode(B, INPUT);
    pinMode(C, INPUT);
}

// This function makes writing the main loop a little easier
// hi should be the Arduino pin that drives the circuit
// lo should be the pin that will act as ground
// off should be the pin that will be set to input to simulat epic resistance
// time_on should be the time the light is on in msecs
// time_off should be the time the light is off in msecs
void routine(int hi, int lo, int off, int time_on, int time_off)
{
    // add some asserts here to ensure nobody did anything foolish when calling
    pinMode(hi, OUTPUT);
    pinMode(lo, OUTPUT);
    digitalWrite(lo, LOW);
    digitalWrite(hi, HIGH);
    delay(time_on);
    digitalWrite(hi, LOW);
    pinMode(hi, INPUT);
    pinMode(lo, INPUT);
    delay(time_off);
}

void loop()
{
    routine(A, B, C, 2000, 500);
    routine(A, C, B, 2000, 500);
    routine(B, A, C, 2000, 500);
    routine(B, C, A, 2000, 500);
    routine(C, A, B, 2000, 500);
    routine(C, B, A, 2000, 500);

}
